﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

public partial class includes_ExitFront : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
            LoadImage();
    }

    private void LoadImage()
    {
        string id = string.Empty;

        if (Request.QueryString["id"] != null)
        {
            id = Request.QueryString["id"].ToString();
        }
        if (!Utils.IsGuid(id))
        {
            return;
        }

        string strQuery = "SELECT FrontImageExit FROM EntryExit WHERE ID=@Id";

        SqlParameter parm = new SqlParameter("@Id", new Guid(id));


        try
        {
            using (DataTable dt = SqlHelper.ExecuteDataset(CommandType.Text, strQuery, parm).Tables[0])
            {

                Byte[] bytes = (Byte[])dt.Rows[0]["FrontImageExit"];
                Response.Buffer = true;
                Response.Charset = "";
                Response.Cache.SetCacheability(HttpCacheability.NoCache);
                Response.ContentType = dt.Rows[0]["FrontImageExit"].ToString();
                Response.AddHeader("content-disposition", "attachment;filename="
                + dt.Rows[0]["FrontImageExit"].ToString());
                Response.BinaryWrite(bytes);
                Response.Flush();
                Response.End();
            }
        }
        catch (Exception)
        {

        }
    }
}